package com.bjpowernode.app;


//线程的生命周期【线程的状态】
//线程阻塞的时候会让出CPU时间片【BLOCKED】【WAITING】【TIMED_WAITING】
//Thread.State
//NEW
//RUNNABLE
//BLOCKED
//WAITING
//TIMED_WAITING
//TERMINATED

public class MyApp1 {
    public static class MyT1 implements Runnable {
        @Override
        public void run() {
            for (int i = 1; i <= 10; i++) {
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(Thread.currentThread().getName()+":"+i);
            }
        }
    }
    public static class MyT2 implements Runnable {
        @Override
        public void run() {
            for (int i = 200; i <= 210; i++) {
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(Thread.currentThread().getName()+":"+i);
            }
        }
    }


    public static void main(String[] args) {

        MyT1 myT1 = new MyT1();
        Thread thread1 = new Thread(myT1, "myt1");
        thread1.start();


        MyT2 myT2 = new MyT2();
        Thread thread2 = new Thread(myT2, "myt2");
        thread2.start();


    }


}
